function signupValidator(form){
    
    var ck_name = /^[A-Za-z0-9 ]{3,20}$/;
    var ck_minit = /^[A-Za-z ]{1,2}$/;
    var ck_email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i ;
    var ck_username = /^[A-Za-z0-9_]{6,20}$/;
    var ck_password =  /^[A-Za-z0-9!@#$%^&*()_]{8,20}$/;
    var noError = true;
    
    if(!ck_username.test(form.username.value)) {
        document.getElementById("usernameError").innerHTML = 'Please enter a valid username.';
        noError = false;
    }else{
        document.getElementById("usernameError").innerHTML = '';
    }
    
    if(!ck_name.test(form.fName.value)) {
        document.getElementById("firstnameError").innerHTML = 'Please enter your firstname.';
        noError = false;
    }else{
        document.getElementById("firstnameError").innerHTML = '';
    }
    
    if(!ck_name.test(form.mName.value)) {
        document.getElementById("middlenameError").innerHTML = 'Please enter your middle name.';
        noError = false;
    }else{
        document.getElementById("middlenameError").innerHTML = '';
    }
    
    if(!ck_name.test(form.lName.value)) {
        document.getElementById("lastnameError").innerHTML = 'Please enter you lastname.';
        noError = false;
    }else{
        document.getElementById("lastnameError").innerHTML = '';
    }
    
    if(!ck_password.test(form.retype.value)) {
        document.getElementById("retypepassError").innerHTML = 'Please confirm password.';
        noError = false;
    }
    if(!ck_password.test(form.password.value)) {
        document.getElementById("passwordError").innerHTML = 'PLease enter a valid password.';
        noError = false;
    }else
    if(form.password.value != form.retype.value){
        document.getElementById("retypepassError").innerHTML = 'Re-type password does not match.';
        noError = false;
    }else{
        document.getElementById("retypepassError").innerHTML = '';
    }
    
    if (!ck_email.test(form.email.value)) {
        document.getElementById("emailError").innerHTML = 'Enter a valid e-mail address.';
        noerror = false;
    }else{
        document.getElementById("emailError").innerHTML = '';
    }
    
  
    return noError;
    
    
}


